# -*- ecoding: utf-8 -*-
# @Author: Wick
# @Time: 2024-02-23 20:46

a = [x for x in range(10)]
print(a)

b = []
for i in range(10):
    b.append(i)
print(b)

# 2 个 for 循环
a = [j for i in range(10) for j in range(i)]
print(a)

#生成二维列表
a = [[col*row for col in range(5)] for row in range(5)]
print(a)
a = [j for x in a for j in x] # 2 维列表转 1 维列表
print(a)

#使用if
d = [x for x in range(10) if x%2==0]  # 将只会筛选偶数
print(a)

#使用if else
a = [x if x % 2 == 0 else x ** 2 for x in range(10)]
print(a)